<?php
/**
 * @version SVN: $Id$
 * @package    fmcSeminaire
 * @subpackage Views
 * @author     EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author     Ludovic Launer {@link }
 * @author     Created on 10-Nov-2010
 * @license    GNU/GPL
 */
$document = &JFactory::getDocument();
$document->addScript('../includes/js/jquery/jquery.js' );
$document->addScript('../includes/js/jquery/jquery.jqGrid-3.8.1/js/i18n/grid.locale-fr.js' );
$document->addScript('../includes/js/jquery/jquery.jqGrid-3.8.1/js/jquery.jqGrid.min.js' );
$document->addScript('../includes/js/jquery/jquery.selectboxes.js' );

$document->addStyleSheet('../includes/js/jquery/jquery.jqGrid-3.8.1/css/ui.jqgrid.css');
$document->addStyleSheet('../includes/js/jquery/jquery-ui-1.8.6.custom/css/ui-lightness/jquery-ui-1.8.6.custom.css');


//-- No direct access
defined('_JEXEC') or die('=;)');

?>
<script type="text/javascript">

// ------------------------------------------------------------------------------------
$.noConflict();
jQuery(document).ready(function(){ 


	jQuery("#list2").jqGrid({ 
		url:'index.php?option=com_fmcseminaire&controller=analyse&task=gtAnalyseData&campagneId=1', 
		datatype: "json", 
		colModel:[
		     		{name:'dateId', 		jsonmap:'dateId', 		width:65},
		     		{name:'Date Debut', 	jsonmap:'dateDebut',	formatter:'date', datefmt:'dd/mm/yyyy'},
		     		{name:'seminaireId', 	jsonmap:'seminaireId',	width:70},
		     		{name:'Seminaire', 		jsonmap:'seminaire',	sorttype:'text'},
		     		{name:'Score', 			jsonmap:'score'						},	
		     	],
     	grouping:true, 
		groupingView : { 
		     			groupField : ['Date Debut'],
		     			groupDataSorted : true,
		     			
		  				},
		jsonReader : 
					{
			     	root:"rows",
		     	 	repeatitems: false,
		     	 	page: "page",
		     	    total: "total",
		     	    records: "records",
		     	   	id: "0"	     	 	
		     		}, 
		loadonce: true,
		loadError: ajaxError,
		height: "auto", 
		caption:"Score des Seminaires", 

		rowNum: "100",
		viewrecords: true, 
		pager : "#gridpager"
		}); 
// ------------------------------------------------------------------------------------
	jQuery("#list_misc_data").jqGrid({ 
		url:'index.php?option=com_fmcseminaire&controller=analyse&task=gtMiscData&campagneId=1', 
		datatype: "json", 
		colModel:[
		     		{name:'Stat', 		jsonmap:'key', sorttype:'text'},
		     		{name:'Valeur', 	jsonmap:'value', sorttype:'text'}
		     	],
		jsonReader : 
					{
			     	root:"rows",
		     	 	repeatitems: false,
		     	 	page: "page",
		     	    total: "total",
		     	    records: "records",
		     	   	id: "0",
		     	   	cell:""	     	 	
		     		}, 
		loadonce: true,
		loadError: function(request, msg) {
					alert("Misc:   " + msg);
					},
		height: "auto", 
		caption:"Statistiques", 

		rowNum: "100",
		viewrecords: true
		}); 
// ------------------------------------------------------------------------------------
function ajaxError(request, msg)
{
	alert(msg);
}
// ------------------------------------------------------------------------------------ 

jQuery("#selCampagne").ajaxAddOption("index.php?option=com_fmcseminaire&controller=analyse&task=gtCampagneListData");


jQuery("#selCampagne").change(function() {
	var selectedValue = jQuery("#selCampagne").selectedValues()[0];
	// --- Analyse ---
  	jQuery("#list2").setGridParam({loadonce:false});
  	jQuery("#list2").setGridParam({datatype: "json", url:'index.php?option=com_fmcseminaire&controller=analyse&task=gtAnalyseData&campagneId=' + selectedValue}); 
  	jQuery("#list2").trigger('reloadGrid'); 
  	jQuery("#list2").setGridParam({loadonce:true});
  	
  	// --- Misc Data ---
	jQuery("#list_misc_data").setGridParam({loadonce:false});
	jQuery("#list_misc_data").setGridParam({datatype: "json", url:'index.php?option=com_fmcseminaire&controller=analyse&task=gtMiscData&campagneId=' + selectedValue}); 
	jQuery("#list_misc_data").trigger('reloadGrid'); 
	jQuery("#list_misc_data").setGridParam({loadonce:true});
	});

//------------------------------------------------------------------------------------ 
});
</script>


<?php 

?>


<div class="header" style="text-align:left">
<label style="margin-top:20px;">Campagne:  </label>
	<select id="selCampagne" name="selCampagne">
	</select>
</div>


<table id="list2"></table>
<div id="gridpager"></div>  
<br>
<table id="list_misc_data"></table>
